home *** CD-ROM | disk | FTP | other *** search
/ Leonardo the Inventor / Leonardo The Inventor (93026)(Broderbund)(Riverdeep)(2004).iso / LEOWINMV / DATABASE.DIR / 00102_Script_General Handlers < prev    next >
Text File  |  1996-03-28  |  2KB  |  70 lines

  1. -- --------------------------------------------------------------
  2. -- Handler validNum
  3.  
  4. on validNum theNum, theMin, theMax
  5.   if theNum < theMin then return theMin
  6.   else if theNum > theMax then return theMax
  7.   else return theNum
  8. end
  9.  
  10. -- --------------------------------------------------------------
  11. -- Handler sortLines returns the given source sorted.
  12.  
  13. on sortLines source
  14.   set out = []
  15.   set numLines = the number of lines of source
  16.   
  17.   repeat with L = 1 to numLines
  18.     add(out, line L of source)
  19.   end repeat
  20.   
  21.   sort out
  22.   set sorted = ""
  23.   
  24.   repeat with L = 1 to numLines
  25.     put getAt (out, L) & RETURN after sorted
  26.   end repeat
  27.   
  28.   return sorted
  29. end
  30.  
  31. -- --------------------------------------------------------------
  32. -- Handler reverseFirstAndSecondItems returns the given source
  33. -- with the first and second items switched.
  34.  
  35. on reverseFirstAndSecondItems source
  36.   set out = ""
  37.   set the itemdelimiter = ":"
  38.   repeat with L = 1 to the number of lines of source
  39.     put (item 2 of line L of source) & ":" & (item 1 of line L of source) & RETURN after out
  40.   end repeat
  41.   set the itemdelimiter = ","
  42.   return out
  43. end
  44.  
  45. -- --------------------------------------------------------------
  46. -- Handler sortInReverseOrder
  47.  
  48. on sortInReverseOrder dataField
  49.   set dataList = []
  50.   set tempVar = field datafield
  51.   
  52.   repeat with i = 1 to the number of lines in tempVar
  53.     add(dataList, line i of tempVar)
  54.   end repeat
  55.   
  56.   sort dataList
  57.   
  58.   set reverseSort = []
  59.   
  60.   set tempVar = EMPTY
  61.   set lineNumber = 1
  62.   
  63.   repeat with i = count(dataList) down to 1
  64.     put getAt(dataList,i) into line lineNumber of tempVar
  65.     set lineNumber = lineNumber + 1
  66.   end repeat
  67.   
  68.   put tempVar into field datafield
  69.   set tempVar = empty
  70. end